package sqs

import (
	"os"
	"xml"
	"goaws.googlecode.com/hg/aws"
)

type errorResponse struct {
	XMLName xml.Name "ErrorResponse"
	Error   struct {
		Type, Code, Message, Detail string
	}
}

func (e *errorResponse) String() string {
	return e.Error.Code + ": " + e.Error.Message
}

func newErrorResponse() os.Error { return new(errorResponse) }

// Queue responses

type listQueuesResponse struct {
	XMLName xml.Name "ListQueuesResponse"
	URLs    []string "ListQueuesResult>QueueUrl"
}

type createQueueResponse struct {
	XMLName xml.Name "CreateQueueResponse"
	URL     string   "CreateQueueResult>QueueUrl"
}

type getQueueAttributesResponse struct {
	XMLName    xml.Name          "GetQueueAttributesResponse"
	Attributes aws.AttributeList "GetQueueAttributesResult>Attribute"
}

// Message responses

type sendMessageResponse struct {
	XMLName          xml.Name "SendMessageResponse"
	MD5OfMessageBody string   "SendMessageResult>MD5OfMessageBody"
	MessageId        string   "SendMessageResult>MessageId"
}

type receiveMessageResponse struct {
	XMLName  xml.Name "ReceiveMessageResponse"
	Messages []struct {
		MessageId     string
		ReceiptHandle string
		Body          string
		MD5OfBody     string
		Attributes    aws.AttributeList ">Attribute"
	} "ReceiveMessageResult>Message"
}
